legislatoR+legislatoR+legislatoR+ is a dashboard project from Benedikt Ströbl and Lukas Warode with the goal to provide an accessible and useful visual tool for the existing legislatoR R package. legislatoR itself is based on The Comparative Legislators Database (Göbel and Munzert, 2021), a far-reaching political science data project that provides both comprehensive information for over 45,000 politicians from ten countries while also including linking possibilities to other research databases within the political science context.
legislatoR+ provides (in the preliminary version) several options of visual communication, including a constituency-based map and 2 descriptive plots. All graphical elements are based on Shiny's reactive infrastructure.
For reasons of accessibility and simplicity that comes with avoiding large data handling issues – the scope of available data differs across the ten countries – the preliminary version for the final project is based on a German sample starting with the 15th legislative period (Bundestagswahl 2002).
Most of the project work took place in a very collaborative dynamic. In the preliminary stages, there was a lively exchange between both project members, with most of the ideas and theoretical approaches of the project having been implicitly worked on jointly.
In the advanced and practical stages, a certain division of labor crystallized. However, a large part of the project was approached in a co-working place, which is why many practical projects and especially problems were evaluated directly together.
In detail, the division of work was as follows:
Benedikt Ströbl mainly took care of the configuration of the HTML template and handled the different map data formats. He also created the visual map base with special emphasis on the constituencies and the implied complex data matching and wrangling tasks.
Lukas Warode was mainly involved in setting up the Shiny backend and did a lot of the practical data manipulation inside and outside the Shiny reactivity context. He also worked on the ggplot2 foundation of the two descriptive statistics and configured the visual and written outline of the R Markdown report.
| Method | koRpus | stringi |
|---|---|---|
| Word count | 2324 | 2241 |
| Character count | 15269 | 15327 |
| Sentence count | 110 | Not available |
| Reading time | 11.6 minutes | 11.2 minutes |
Many research projects in academia suffer from lacking visibility, even though their scope and findings could be relevant and appealing to a broader audience. The same is true for scientific articles in general, however, especially data-driven research projects exhibit great potentials for further research ideas and serve as a crucial foundation in the domain of genuine knowledge generation.
In this context, setting up a proper and suitable dashboard should function as an instrument of appealing and barrier-free visual communication. The goal of the dashboard – legislatoR+ – is to reach both an academic and non-academic audience while generally trying to increase the visibility and accessibility of The Comparative Legislators Database, or rather the legislatoR package.
R package legislatoRThe package legislatoR is available on CRAN since April 2020. The download dynamics of the package are shown in Figure 1. It is hard to observe a clear pattern or direction within the download behavior, however, in the year 2020, there is a small downward trend observable. Since fall 2021, the download pattern is showing an increase again, while showing some days with surpassingly high download numbers.
The table on the the right side is indicating the quarterly download numbers. The quarterly downloads range from 920 (last quarter 2020) to 1258 (last quarter 2021). The highest number of downloads in the ongoing quarter could be an indicator that the package or rather the project itself is facing an increased importance and visibility.
legislatoR
| Year | Quarter | Download (N) |
|---|---|---|
| 2020 | 2 | 997 |
| 2020 | 3 | 1073 |
| 2020 | 4 | 920 |
| 2021 | 1 | 922 |
| 2021 | 2 | 1001 |
| 2021 | 3 | 924 |
| 2021 | 4 | 1275 |
Figure 2 shows a sketch made by both project members that shows the dashboard in almost the identical format as it is submitted for the final project assignment. Both the map and the two descriptive statistics are integral part of the legislatoR+'s scope. Note: The Appendix includes another sketch that exhibits a more detailed and analytical approach of the dashboard.
The package legislatoR provides nine individual tables that can be both used individually and combined after merging with the respective key variables. For the scope of this project, the tables Core, Political and Portraits are used, which are highlighted in Figure 2. All three tables can be merged using the pageid key variable.
The respective tables are used for different purposes within legislatoR+'s scope:
Core serves as the main table and provides sociodemographic information on legislators. For the scope of legislatoR+, the variables name, birth and death are very important. The last two are used in order to compute the individual age of legislators.
Political provides relevant information of the genuine political activity of included legislators. The table serves as the essential source of communicated information in the dashboard project. The variable session represents the legislative period of the MP (Member of Parliament), while party indicates the party affiliation of the politician. Both variables play a crucial role for the displayed plots in the dashboard. Furthermore, constituency is used to map the MPs per legislative period, while session_start and session_end serve for computing the maximum term length of individual MPs.
Portraits just includes the variable image_url next to the pageid. image_url provides the URL to the portrait images that are displayed on the respective (English) Wikipedia articles. The portrait images serve as an important visual element within the map of the dashboard and are also representing a crucial recognition value for the audience inside and outside of academia.
| Table | Function | Description | Key |
|---|---|---|---|
| Core | get_core() |
Fetches sociodemographic data of legislators | pageid, wikidataid |
| Political | get_political() |
Fetches political data of legislators | pageid |
| History | get_history() |
Fetches full revision histories of legislators’ Wikipedia biographies | pageid |
| Traffic | get_traffic() |
Fetches daily user traffic on legislators’ Wikipedia biographies | pageid |
| Social | get_social() |
Fetches social media handles and website URLs of legislators | wikidataid |
| Portraits | get_portrait() |
Fetches portrait urls of legislators | pageid |
| Offices | get_office() |
Fetches political and other offices of legislators | wikidataid |
| Professions | get_profession() |
Fetches occupational data of legislators | wikidataid |
| IDs | get_ids() |
Fetches a range of IDs of legislators | wikidataid |
The scope of this version (Final Data Science Project) includes some constraints. From the ten country sample, only legislators from Germany are used that are chronologically at least part of the 15th legislative period. The current state of legislatoR does not include the most recent legislative period of the Bundestag (20), hence, MPs from legislative period 15 to 19 are part of legislatoR+'s sample.
The cut-down version of legislatoR+ (in relation to the full dataset) is mainly due to two reasons: First, the scope of this project is to introduce The Comparative Legislators Database in a visual and approachable manner. A small subset of the database is a better fit for this goal since the chances of potential overstrainings are reduced while performance and accessibility are increased. Second, one of the core visual elements is a leaflet map, which is serving as a constituency-based choropleth map, was rather complex to set up. Since providing a stable and dynamically adjusted choropleth map based on the given untidy and unmerged datasets – including the changing geographical and political boundaries of German constituencies – was already a work-heavy and detailed task, the project members decided to not include further countries for the scope of the project in the first step, also considering the emphasis of the lecturers to not work on too big or too complicated tasks.
deu_political <- get_political("deu")
paste0(
"Number of Observations: ",
deu_political %>%
filter(session >= 15) %>%
nrow
)
## [1] "Number of Observations: 3297"
paste0(
"Number of Unique Observations: ",
deu_political %>%
filter(session >= 15) %>%
distinct(pageid) %>%
nrow
)
## [1] "Number of Unique Observations: 1530"
The main graphical elements of the dashboard are two descriptive statistics and a constituency-level map of Germany. The two descriptive statistics show the distribution of MPs’ age and (total) term of office in years respectively as Figure 5 shows. Both plots are presenting the density while being accompanied by a boxplot beneath the plotted density curve. In addition the (exact value of the) median is highlighted, next to the number of observations. In this case, Wolfgang Schäuble is selected, who is older than the average MP of the 19th legislative session and is also exceptionally long in office, as both descriptive statistics indicate.
The reactive Shiny context enables a dynamic handling of the underlying data structure. Users can subset the data manually by using the input parameters Select Legislative Sessions and Select Parties. In addition, individual MPs can also be selected by the parameter MP Name. Selected MPs are highlighted in both descriptive plots with a vertical line that is showing the data point within the selected distribution. Below the respective plots, there are download buttons (SAVE PLOT) that enable users to download the current version of the respective plot as a .png file.
The input selection not only updates and generates descriptive statistics, but also maps the current selection on a constituency-level, as shown in Figure 6. The leaflet map is reactively updated to every available of the three input paramters. When more than one legislative sesion is selected, the results of the most recent session are displayed. Selecting parties leads to highlighting all constituencies that were won in the respective federal election. When a party and an MP are selected, both are visually marked, while the constituency is highlighted with less opacity in order to accentuate them visually.
Clicking on a single constituency opens a pop-up feature that gives a brief overview in the form of a small fact sheet of the political career of the respective MP. Next to the image of the individual MPs and the logo of the affiliated party, information on served sessions, age and the name of the constituency are presented.
One of the main goals of legislatoR+ is to function as a visual appealing and intuitive access to the legislatoR database. However, the long-run goal of the dashboard application is also to include more functionalities in addition to expanding the scope of used data. Both parts of the long-run goal are referring to then concept of scalability: Based on the existing framework of the final project scope, new features – in the form of additional “dashboard views” or added data – should be easy to add while also representing a useful addition to the existing scope.
A useful and accessible dashboard should increase the vision of its underlying database. Both the package legislatoR and the Comparative Legislators Database itself should be positively affected by a useful dashboard. There should also be a strong synergy between newly added elements and reached target audience. For instance, it can be assumed that potential users from a certain country are more likely to use the dashboard when there country is also part of the application. Increasing visibility within academia would also imply that certain data tables from the Comparative Legislators Database that are of particular interest for a research-affine group could be added according to a intra-academic demand principle. While the dashboard in the final project version does not feature any analytical or even causal elements, those statistical features normally exhibit more differentiated insights and are thus specifically relevant for the academic context.
The principle of modularity is directly implied theoretically and especially practically in the notion of scalability. In practical terms, modularity refers to a system that enables new features to be added in a very straightforward and inherent manner. For legislatoR+ this would translate to adding visual and analytical elements of the legislatoR package that are easy to implement in the given dashboard structure. The current dashboard is mainly set up by 3 visual elements: A comprehensive choropleth map and two plots that communicate descriptive statistics. Adding a new map would be rather complicated and implying a lot of obstacles, while modularly adding new elements, for instance new information for the MPs and more legislative periods, would be a rather straightforward approach. The two existing plots could also be easily expanded or complemented by similar visual features that are based on the same level of inputs in Shiny's reactivity context.
Configuring a stable and consistent constituency-level map was one of the main obstacles of the project. First, there were many changes in the set up of political constituencies in the last decades that involved a manual merging approach of the respective geographical data files. Second, some constituencies were named differently across the different data sets that had to be merged. For instance, in one data file, there were spaces inserted, preceding and following a minus symbol in a double name, where the other data set did not used spaces.
The shapefiles acquired from the Bundeswahlleiter for the 2009 and 2013 federal elections revealed differences in the data structure, such as missing values, duplicated rows, additional columns and other inconsistencies, which provided some difficulties for data manipulation and merging purposes within the project.
The previous chapters have shown that legislatoR+ exhibits various possibilities to be extended in the future. While the dashboard already offers to retrieve information from a subset – German MPs from the 15th to the 19th legislative period – in a visual and descriptive manner, the possibilities to scale the existing application are certainly given. Adding more countries of legislatoR to the dashboard would increase the project’s visibility, while prospective added modules could also be used to apply statistical models within the data structure and thus enhance the dashboard’s scope to an analytical framework.
Göbel, S., & Munzert, S. (2020). Introducing legislatoR.
Göbel, S., & Munzert, S. (2021). The Comparative Legislators Database. British Journal of Political Science, 1-11. doi:10.1017/S0007123420000897